/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
/**
 *
 * $Id: protocolID.h,v 1.1 2008-03-30 00:55:36 amaula Exp $
 *
 */
#ifndef _PROTOCOLID_H_
#define _PROTOCOLID_H_

#define PROTOCOL_FLAGBIT(bit) (1<<(bit))
#define PROCOTOL_GETPAYLOADSIZE(apid, hdrsize) (apid->total_size - hdrsize)
#define PROTOCOL_TOTAL2PAYLOAD(p_total_size) \
        ((p_total_size) - sizeof(TProtocolIdentification))
#define PROTOCOL_PAYLOAD2TOTAL(p_payload_size) \
        ((p_payload_size) + sizeof(TProtocolIdentification))

/**
 * This is the compulsory
 *
 */
typedef struct _protocolIdentification
{
  unsigned total_size         : 28;      ///< Datagram total size (Including this)
  unsigned protocol_number    : 4;       ///< Protocol number

} TProtocolIdentification;
#define SIZEOF_TPROTOCOLIDENTIFICATION (4)

void protocolIdentificationConstructHeader(TProtocolIdentification *p,
					   int protocol_number,
					   int total_size);

void protocolIdentificationDumpHeader(int l, const TProtocolIdentification *protocol_id);


#endif // _PROTOCOLID_H_
